import java.util.Scanner;


public class UniqueWords 
{

	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		//s.useDelimiter("(\\s)*");
		Scanner s1;
		System.out.println("Enter the sentence:");
		String original ="";
		String first[]=new String[10];
		int i =0;
		
		try
		{
			original = s.nextLine();
			s1 = new Scanner(original);
			while (s1.hasNext())
			{
				first[i] = s1.next();
				i++;
			}
		}
		catch(Exception e)
		{
			System.out.println("\n"+e+"\n");
		}
		s.close();
		
		//identifying unique and duplicates
		boolean duplicate;
		int x=0,z=0,j=0;
		int size =i;
		String unique[] = new String[size];
		String dup[] = new String[size];
				
		// for loop to form the duplicate list
		for (i=0;i<size;i++)
		{
			duplicate = false;
			for(j=i+1;j<=size-1;j++)
			{
				if ((first[i].compareTo(first[j])) == 0)
				{
					duplicate = true;				
				}
			}//end of inner for lop
			if (duplicate)
				dup[z++]=first[i];
		}//end of outer for loop
				
		// for loop to form the unique list
			
		for (i=0;i<size;i++)
		{
			duplicate = false;
		
			for(j=0;j<z;j++)
			{
				if ((first[i].compareTo(dup[j])) == 0)
				{
					duplicate = true;	
				}
					
			}//end of inner for lop
			if (!duplicate)
				unique[x++]=first[i];
		}//end of outer for loop
				
		System.out.println("\nUnique list:\n");
				
		for(i=0;i<x;i++)
		{
			System.out.print(unique[i]+" ");
		}
	}
}


